home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 51 / Amiga Format CD51 (2000-03-10)(Future Publishing)(GB)[!][issue 2000-04].iso / -in_the_mag- / workbench / term_4.8 / extras / source / gtlayout-source.lha / LTP_DrawIncrementer.c < prev    next >
C/C++ Source or Header  |  1997-05-08  |  1KB  |  61 lines

  1. /*
  2. **    GadTools layout toolkit
  3. **
  4. **    Copyright © 1993-1997 by Olaf `Olsen' Barthel
  5. **        Freely distributable.
  6. **
  7. **    :ts=4
  8. */
  9.  
  10. #ifndef _GTLAYOUT_GLOBAL_H
  11. #include "gtlayout_global.h"
  12. #endif
  13.  
  14. #include "Assert.h"
  15.  
  16. VOID
  17. LTP_DrawIncrementer(struct RastPort *rp,struct DrawInfo *drawInfo,BOOL leftDirection,LONG left,LONG top,LONG width,LONG height)
  18. {
  19.     LONG arrowWidth,arrowHeight;
  20.     LONG mid,a,b,inc,i;
  21.  
  22.     arrowWidth    = (width < height ? width : height) - 4;
  23.     arrowHeight    = (drawInfo->dri_Resolution.X * arrowWidth) / drawInfo->dri_Resolution.Y;
  24.  
  25.     if(arrowHeight < 5)
  26.         arrowHeight = 5;
  27.  
  28.     if(arrowHeight > height)
  29.         arrowHeight = height;
  30.  
  31.     arrowHeight = ((arrowHeight - 1) & ~1) + 1;
  32.  
  33.     left    += (width - arrowWidth) / 2;
  34.     top        += (height - arrowHeight) / 2;
  35.  
  36.     mid = top + arrowHeight / 2;
  37.  
  38.     if(leftDirection)
  39.     {
  40.         a    = left + arrowWidth - 1;
  41.         b    = left;
  42.         inc    = 1;
  43.     }
  44.     else
  45.     {
  46.         a    = left;
  47.         b    = left + arrowWidth - 1;
  48.         inc    = -1;
  49.     }
  50.  
  51.     for(i = 0 ; i < 4 ; i++)
  52.     {
  53.             // Note: two calls to ensure symmetry
  54.  
  55.         LTP_DrawLine(rp,a,top,b,mid);
  56.         LTP_DrawLine(rp,a,top + arrowHeight - 1,b,mid);
  57.  
  58.         b += inc;
  59.     }
  60. }
  61.